package com.jorkyin.hfmusic.ui.main;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.jorkyin.hfmusic.R;

public class MusicListFragment extends Fragment {
    private MusicListAdapter adapter;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_music_list, container, false);

        RecyclerView recyclerView=view.findViewById(R.id.recyclerView);

        adapter = new MusicListAdapter(getActivity());
        LinearLayoutManager layoutManager= new LinearLayoutManager(getActivity());
        recyclerView.setLayoutManager(layoutManager);
        recyclerView.setAdapter(adapter);
        return view;
    }

    @Override
    public void onStart() {
        super.onStart();

        adapter.addMusic(new Music("我和我的祖国","群星"));
        adapter.addMusic(new Music("喜欢你","邓紫棋"));
        adapter.addMusic(new Music("我的祖国","宋祖英"));
        adapter.addMusic(new Music("牛郎织女","萌萌哒天团"));
        adapter.addMusic(new Music("大田后生仔","林啟得"));
        adapter.addMusic(new Music("孤芳自赏","杨小状"));
        adapter.addMusic(new Music("狐狸","薛之谦"));
        adapter.addMusic(new Music("琵琶行","杨娇"));
        adapter.addMusic(new Music("女儿国","李荣浩"));
    }
}
